1. /* smmerror.cpp by K.Tsuru */
  2. /****************
  3. SNManager class
  4. error handler
  5. ******************/
  6. #ifndef SN_H
  7. #include "sn.h"
  8. #endif
  9. #include "version.h"
  10. /**************************************************************************
  11. Definition in SNManager class
  12. enum SNErrorFlag {
  13. NO_ERR = 0, OVERFLOW_ERR, UNDERFLOW_ERR, DIVIDED_BY_ZERO, SIGN_ERR,
  14. NOT_CONVERGE, DOMAIN_ERR, OUT_OF_RANGE, RADIX_ERR, UNDEC_VALUE,
  15. SET_EFF_FIG, SYNTAX_ERR, FFT_ERR, TOO_LONG, TOO_LARGE_EXP,
  16. TLOSS_ERR, VERIFY, FATAL
  17. };
  18. ***************************************************************************/
  19. static const char* const ErrorMsg[]={
  20. SN_Lib_Version,
  21. "Overflow",
  22. "Underflow",
  23. "Divided by 0",
  24. "Sign", // XXAdd, XXSub must be same sign.
  25. "Series did not converge",
  26. "Domain", // Mathematical error
  27. "Out of range", // Not mathematical error but argument of function was out of range.
  28. "Radix",
  29. "Undecided number operation in substitution/output",
  30. "Usage of SetEffFig()", // SetEffFig(n);.... SetEffFig(0); || isA() != SN_MANEGER
  31. "Syntax", // "0.abcd.efg" in StringToNumber etc.
  32. "FFT", // LLMultFFT()
  33. "Given number was too long", // "abcdefg..." in StringToNumber etc.
  34. "Exponent is too large/small",
  35. "Effective figures lost",
  36. "Verification",
  37. "Fatal", // Constructor of SNumber class. figure[i] >= radix in CheckArray().
  38. "",
  39. };
  40. // function ID = 001
  41. void SNManager::ErrorHandler(int errID){
  42. if(errID > 0) fputs("\nError :", stderr);
  43. else fputs("\nWarning :", stderr);
  44. if( *place || (place!= NULL) ){
  45. fputs(place, stderr); fputc(' ',stderr);
  46. }
  47. fprintf(stderr,"%s. ID = %d\n", ErrorMsg[errorFlag], errID);
  48. if(errID > 0) exit(EXIT_FAILURE);
  49. }
  50. // function ID = 008
  51. void SNManager::SetError(SNErrorFlag error_flag, const char* pl, int errID){
  52. if( (error_flag == NO_ERR) || !errID){ // Version
  53. fprintf(stderr,"%s.\n", ErrorMsg[0]);
  54. return;
  55. }
  56. int len = (pl == NULL) ? 0 : strlen(pl);
  57. delete[] place;
  58. place = new char[len+1];
  59. if(len) strcpy(place, pl);
  60. else *place = '\0';
  61. errorFlag = error_flag;
  62. ErrorHandler(errID);
  63. }

smmerror.cpp : last modifiled at 2015/11/27 14:48:24(2,130 bytes)
created at 2016/04/11 11:36:47
The creation time of this html file is 2017/10/27 10:59:17 (Fri Oct 27 10:59:17 2017).